package com.ksd.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ksd.common.annotation.Log;
import com.ksd.common.core.controller.BaseController;
import com.ksd.common.core.domain.AjaxResult;
import com.ksd.common.core.page.TableDataInfo;
import com.ksd.common.enums.BusinessType;
import com.ksd.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ksd.system.domain.SysMusicAlbum;
import com.ksd.system.service.ISysMusicAlbumService;

/**
 * 音乐专辑Controller
 * 
 * @author y.wu
 * @date 2025-09-05
 */
@RestController
@RequestMapping("/system/musicAlbum")
public class SysMusicAlbumController extends BaseController
{
    @Autowired
    private ISysMusicAlbumService sysMusicAlbumService;

    /**
     * 查询音乐专辑列表
     */
    @PreAuthorize("@ss.hasPermi('system:musicAlbum:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysMusicAlbum sysMusicAlbum)
    {
        startPage();
        List<SysMusicAlbum> list = sysMusicAlbumService.selectSysMusicAlbumList(sysMusicAlbum);
        return getDataTable(list);
    }

    /**
     * 导出音乐专辑列表
     */
    @PreAuthorize("@ss.hasPermi('system:musicAlbum:export')")
    @Log(title = "音乐专辑", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysMusicAlbum sysMusicAlbum)
    {
        List<SysMusicAlbum> list = sysMusicAlbumService.selectSysMusicAlbumList(sysMusicAlbum);
        ExcelUtil<SysMusicAlbum> util = new ExcelUtil<SysMusicAlbum>(SysMusicAlbum.class);
        util.exportExcel(response, list, "音乐专辑数据");
    }

    /**
     * 获取音乐专辑详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:musicAlbum:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysMusicAlbumService.selectSysMusicAlbumById(id));
    }

    /**
     * 新增音乐专辑
     */
    @PreAuthorize("@ss.hasPermi('system:musicAlbum:add')")
    @Log(title = "音乐专辑", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysMusicAlbum sysMusicAlbum)
    {
        return toAjax(sysMusicAlbumService.insertSysMusicAlbum(sysMusicAlbum));
    }

    /**
     * 修改音乐专辑
     */
    @PreAuthorize("@ss.hasPermi('system:musicAlbum:edit')")
    @Log(title = "音乐专辑", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysMusicAlbum sysMusicAlbum)
    {
        return toAjax(sysMusicAlbumService.updateSysMusicAlbum(sysMusicAlbum));
    }

    /**
     * 删除音乐专辑
     */
    @PreAuthorize("@ss.hasPermi('system:musicAlbum:remove')")
    @Log(title = "音乐专辑", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysMusicAlbumService.deleteSysMusicAlbumByIds(ids));
    }
}
